package org.magenta.pages;

import org.magenta.data.AdminData;
import org.magenta.utils.configProperties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class loginPageBE extends Page {

	
	@FindBy(id = "username")
	public WebElement fieldUsername;
	
	@FindBy(id = "login")
	public WebElement fieldPassword;
	
	@FindBy(className ="form-button")
	public WebElement buttonLogin;
	
	
	
	
	public loginPageBE(WebDriver driver) {
		super(driver);
	}
	
	public Dashboard loginAs (AdminData admin) {
		type(fieldUsername, admin.name);
		type(fieldUsername, admin.password);
		buttonLogin.click();
		return PageFactory.initElements(driver, Dashboard.class);
	}
	
	public boolean isloggedOut () {
	 return isElementPresent(buttonLogin);
	}
	
	@Override
	public void open() {
		driver.get(configProperties.getProperty("url.be"));	
	}

}
